<template>
  <div>
    <common-title :stitle="alldata.stitle"></common-title>
    <div style="font-size: smaller; color: gray;">{{ alldata.mes }}</div>
    <!--<van-cell-group>
      <van-cell v-for="(coldata, index) in alldata.alertdata" :key="index" :value="coldata" />
    </van-cell-group>-->
    <template v-for="alert in reldatas">
      <div v-if="alert.datas.length > 0" style="max-height: 280px; overflow: auto; margin-top: 10px;" :key="alert.obj">
        <div>{{ alert.msg }}</div>
        <el-table :border="true" :data="alert.datas" @row-click="tableClick">
          <el-table-column v-for="col in alert.titles" :label="col.label" :prop="col.prop" :key="col.label">
          </el-table-column>
        </el-table>
      </div>
    </template>
  </div>
</template>

<script>
import Vue from 'vue'
import { Cell, CellGroup } from 'vant'
import commonTitleMixin from '../mixins/commonTitleMixin'
Vue.use(Cell).use(CellGroup)
export default {
  name: 'alert',
  data: function () {
    return {
      alertdata: [],
      reldatas: []
    }
  },
  props: ['alldata'],
  mixins: [commonTitleMixin],
  mounted () {
    this.alertdata = this.alldata.alertdata
    for (var i = 0; i < this.alertdata.length; i++) {
      this.reldatas[i] = JSON.parse(this.alertdata[i])
    }
    // //console.log('alert', this.reldatas)
    this.$forceUpdate() // 强制更新视图，不加不显示数据
  },
  methods: {
    tableClick: function (row, column) {
      let bo = column.property.substring(0, column.property.indexOf('_'))
      let itemid = row[bo + '_id']
      //console.log(itemid, bo)
      this.$router.push({ name: 'card', query: { itemid: itemid, idobject: bo, idtemplate: '' } })
    }
  }
}
</script>

<style scoped></style>
